package com.control;
import com.service.ITestService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/test")
public class TestController {

    private static final Logger logger = LoggerFactory.getLogger(TestController.class);

    @Autowired
    ITestService iTestService ;

    @Value("${server.port}")
    private String port ;

    @GetMapping("/query")
    public Map<String,Object> testSentinel(Long id) throws InterruptedException {

        Map<String, Object> map = iTestService.queryById(id);
        System.out.println("=====控制层"+map);
        return map;
    }

    @GetMapping("/test")
    public Map<String,Object> test(Long id) throws InterruptedException {

        Map<String, Object> map = iTestService.queryById(id);
        System.out.println("=====控制层"+map);
        return map;
    }

    @GetMapping("/demo")
    public Map<String,Object> demo(Long id) throws InterruptedException {

        Map<String, Object> map=new HashMap<>();
        map.put("msg","欢迎光临");
        map.put("port",port);
        return map;
    }

    @PostMapping("/login")
    public Map<String,Object> demo2(String username,String password) throws InterruptedException {

        Map<String, Object> map=new HashMap<>();
        map.put("msg",username+"欢迎光临");
        map.put("port",port);
        return map;
    }
}
